﻿<!--#include file="utf-8.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="seeion.asp"-->
<!--#include file="page.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新闻分类管理</title>
<link href="images/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="head"><strong>新闻分类管理</strong></td>
</tr>
<tr>
<td>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="head_chile">
    <tr>
    <td width="35%">分类名称（中文）</td>
    <td width="35%">分类名称（英文）</td>
    <td width="10%" align="center">排序</td>
    <td width="10%" align="center">修改新闻</td>
    <td width="10%" align="center">删除新闻</td>
    </tr>
    </table>
<%	
set rs=server.createobject("adodb.recordset") 
exec="select * from Sort_News order by OrdersID asc" 
rs.open exec,conn,1,1 
if rs.eof then
response.Write "&nbsp;暂无分类！"
else
rs.PageSize =20 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if	
%>
<%For i=1 To x%>
<form  name="add" method="post" action="admin_news_sort.asp?type=update">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="35%" height="30"><input name="title" type="text" class="textbox" value="<%=rs("Name")%>"></td>

	<input name="id" type="hidden" id="id" value="<%=rs("id")%>" />
    
    <td width="35%" height="30"><input name="etitle" type="text" class="textbox" value="<%=rs("eName")%>"></td>
    <td width="10%" height="30" align="center"><input name="OrdersID" type="text" class="textbox" value="<%=rs("OrdersID")%>" size="2"></td>
    <td width="10%" height="30" align="center"><input class="button" type="submit" name="button" id="button" value="修改分类"></td>
    <td width="10%" height="30" align="center"><input class="button" type="button" name="Submit" value="删除分类" onClick="javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='admin_news_sort.asp?type=del&id=<%=rs("id")%>';}else{history.go(0);}" /></td>
    </tr>
    </table>
</form>
    <%rs.movenext
    next
    %>
    <%end if%>
    </td>
    </tr>
    </table>
    
    <br>
    
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td class="head"><strong>添加新闻分类</strong></td>
    </tr>
    <tr>
    <td>
    
    <form name="form1" method="post" action="admin_news_sort.asp?type=add">
    
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="head_chile">
        <tr>
        <td width="35%">分类名称（中文）</td>
        <td width="35%">分类名称（英文）</td>
        <td width="10%" align="center">排序</td>
        <td width="10%" align="center">&nbsp;</td>
        <td width="10%" align="center">操作</td>
        </tr>
        </table>
    
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
        <td width="35%" height="30"><input name="title" type="text" class="textbox" id="title"></td>
        <td width="35%" height="30"><input name="etitle" type="text" class="textbox" id="etitle"></td>
        <td width="10%" align="center"><input name="OrdersID" type="text" class="textbox" id="OrdersID" size="2"></td>
        <td width="10%" height="30" align="center">&nbsp;</td>
        <td width="10%" height="30" align="center"><input name="button2" type="submit" class="button_01" id="button2" value="增加分类"></td>
        </tr>
        </table>
    </form>
</td>
</tr>
</table>
</body>
</html>

<% 
if Request.QueryString("type")="update" then
	id=request("id") 
	sql="select * from Sort_News where id="&id 
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,3
	IF not isNumeric(request("OrdersID")) then
		response.write("<script>alert(""排序ID必须为数字！""); history.go(-1);</script>")
		response.end
	end if
	rs("Name")=request.form("title") 
	rs("eName")=request.form("etitle") 
	rs("OrdersID")=request.form("OrdersID") 
	rs.update 
	rs.close 
	response.Write("<script language=""javascript"">alert(""修改新闻分类成功！"");window.location.href='admin_news_sort.asp';</script>")
end if
%> 

<%
if request("type")="del" then
	id=Request.QueryString("id")
	sql="select * from Sort_News where id="&id
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,2,3
	rs.delete
	rs.update
	Response.Write "<script>alert('新闻分类刪除成功！');window.location.href='admin_news_sort.asp';</script>"
end if 
%>

<%
if Request.QueryString("type")="add" then
	sql="select * from Sort_News"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,3
	title=request.form("title")
	etitle=request.form("etitle")
	OrdersID=request.form("OrdersID")
	if title="" then 
		response.Write("<script language=javascript>alert('中文名称不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if etitle="" then 
		response.Write("<script language=javascript>alert('英文名称不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if OrdersID="" then 
		response.Write("<script language=javascript>alert('排序ID不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	IF not isNumeric(request("OrdersID")) then
		response.write("<script>alert(""排序ID必须为数字！""); history.go(-1);</script>")
		response.end
	end if
	rs.addnew
	rs("Name")=title
	rs("eName")=etitle
	rs("OrdersID")=OrdersID
	rs.update
	rs.close
	set rs=nothing
	Response.Write "<script>alert('分类增加成功！');window.location.href='admin_news_sort.asp';</script>" 
end if
%>

